#include<cstdio>
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(r-l+1>=n){
		printf("%d",n-1);
		return 0;
	}
	r%=n,l%=n;
	printf("%d",(l<r?r:n-1));
	return 0;
}
